const path = require("path");
const fs = require("fs");

// console.dir(path);

//  join 路径的拼接方法

// __dirname 返回当前模块所处文件路径 （绝对路径）
// __filename 返回当前模块的绝对路径
console.log(__dirname);
console.log(__filename);


console.log(path.join("a","b","c"));
console.log(path.join(__dirname,"a.txt"));


let fpath = path.join(__dirname,"a.txt");
fs.writeFile(fpath,"hello path",error =>{
    console.log(error);
})


// 可以获取路径中的文件名
console.log(path.basename(__filename,".js"));

console.log(path.extname(__filename));
